<template>
	<view class="content">
		<view class="card">
			<step v-model="index"></step>
		</view>
		<view v-if="index==1" class="card">
			<cell title='企业名称' v-model="formData.qymc" required></cell>
			<cell title='统一社会信用代码' v-model="formData.xydm" required></cell>
			<cell title='法定代表人姓名' v-model="formData.dbrxm" required></cell>
			<cell title='法定代表人身份证号' mode="input" v-model="formData.dbrCrad" required></cell>
			<cell title='业务办理城市' mode="region" v-model="formData.ywblcs" required></cell>
			<cell title='期望业务办理机构' mode="selector" v-model="formData.qdbljg" :selectorItem="selectorItem" required>
			</cell>
			<cell title='推荐人' v-model="formData.tjr"></cell>
			<!-- <cell title='日期' mode="date" v-model="formData.date"></cell>
			<cell title='时间' mode="time" v-model="formData.time"></cell> -->
		</view>
		<view v-if="index==2" class="card">
			<cell title='身份认证' mode="jump" jumpUrl="/pages/science/sfrz" :jumpBtn="['未认证','已认证']"
				v-model="formData2.sfrz" required></cell>
			<cell title='信息采集' mode="jump" jumpUrl="/pages/science/xxlr" :jumpBtn="['未录入','已录入']"
				v-model="formData2.xxcj" required></cell>
			<cell title='税务认证' mode="jump" jumpUrl="/pages/science/swrz" :jumpBtn="['未认证','已认证']"
				v-model="formData2.swrz" required></cell>
		</view>
		<view v-if="index==3" class="success-tip">
			<view class="card">
				<icon type="success" size="130" />
				<br>
				<view class="tip2">尊敬的客户，你已完成贷款。</view>
				<view class="tip2">我行经理将在3个工作日内与你取得联系，请您耐心等候。</view>
			</view>
			<button class="btn" size="default" type="primary" @click="backHome()" hover-class="is-hover">返回首页</button>
		</view>
		<ReadmeBtn v-if="index!=3" fixed :readme="['交通银行小微授信业务个人信息处理授权书','征信机构个人信息授权书']" :text="btntext"
			@submit="submit"></ReadmeBtn>
	</view>
</template>

<script>
	import step from "@/components/step.vue"
	export default {
		components: {
			step
		},
		data() {
			return {
				index: 1,
				btntext: '下一步',
				selectorItem: [{
						value: '1',
						label: '业务1'
					},
					{
						value: '2',
						label: '业务2'
					}
				],
				formData: {
					qymc: '成都xx农业科技有限公司',
					xydm: 'D11233******',
					dbrxm: '张三',
					dbrCrad: '511018****',
					ywblcs: '',
					qdbljg: '1',
					tjr: '',
					// date:'',
					// time:''
				},
				formData2: {
					sfrz: '',
					xxcj: '',
					swrz: ''
				}
			}
		},
		onShow() {
			this.formData2.sfrz = uni.getStorageSync('isIDAuth')
			this.formData2.xxcj = uni.getStorageSync('isInsertInfo')
			this.formData2.swrz = uni.getStorageSync('isImgCollect')
		},
		methods: {
			backHome() {
				uni.navigateBack({delta: 10})
			},
			toast(title) {
				uni.showToast({
					icon: "none",
					title,
				})
			},
			async submit() {

				if (this.index === 1) {
					if (!this.formData.qymc) {
						this.toast('请输入企业名称')
						return
					}
					if (!this.formData.xydm) {
						this.toast('请输入统一社会信用代码')
						return
					}
					if (!this.formData.dbrxm) {
						this.toast('请输入法定代表人姓名')
						return
					}
					if (!this.formData.dbrCrad) {
						this.toast('请输入法定代表人身份证号')
						return
					}
					if (!this.formData.ywblcs) {
						this.toast('请选择业务办理城市')
						return
					}
					if (!this.formData.qdbljg) {
						this.toast('请选择期望业务办理机构')
						return
					}
					await this.$myloading() // async
				} else if (this.index === 2) {
					if (!this.formData2.sfrz) {
						this.toast('请完成身份认证')
						return
					}
					if (!this.formData2.xxcj) {
						this.toast('请完成信息采集')
						return
					}
					if (!this.formData2.swrz) {
						this.toast('请完成税务认证')
						return
					}
					await this.$myloading() // async
				}

				if (this.index < 3) {
					this.index++
				}
			}
		}
	}
</script>


<style lang="scss" scoped>
	
</style>